package com.ym.b2b.complaint.dao.impl;

import java.util.HashMap;
import java.util.Map;

import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Repository;

import com.ym.b2b.commons.dao.BaseDao;
import com.ym.b2b.complaint.dao.EmBReplyDAO;
import com.ym.b2b.complaint.sqlbean.EmBReply;
import com.zc.commons.base.Page;

@Repository
public class EmBReplyDAOImpl<T> extends BaseDao<T> implements EmBReplyDAO {

    @Override
    public void insertEmBReply(EmBReply record) throws DataAccessException {
        insert("EM_B_REPLY.insertEmBReply", record);
    }

    @Override
    public int updateEmBReply(EmBReply record) throws DataAccessException {
        int rows = sqlMapClient.update("EM_B_REPLY.updateEmBReply", record);
        return rows;
    }

    @Override
    public EmBReply searchEmBReply(Long replyId) throws DataAccessException {
        EmBReply key = new EmBReply();
        key.setReplyId(replyId);
        EmBReply record = (EmBReply) sqlMapClient.queryForObject("EM_B_REPLY.selectEmBReply", key);
        return record;
    }

    @Override
    public int deleteEmBReply(Long replyId) throws DataAccessException {
        EmBReply key = new EmBReply();
        key.setReplyId(replyId);
        int rows = sqlMapClient.delete("EM_B_REPLY.deleteEmBReply", key);
        return rows;
    }

    @Override
    public Long searchPageEmBReplyNum(EmBReply emBReply) throws DataAccessException {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("map", emBReply);
        return (Long) listNum("EM_B_REPLY.searchPageEmBReplyNum", map);
    }

    @Override
    public Page searchPageEmBReply(EmBReply emBReply, Page<EmBReply> page) {
        page.setTotalRow(searchPageEmBReplyNum(emBReply));
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("map", emBReply);
        map.put("startrow", page.getStartRow());
        map.put("pagesize", page.getPageSize());
        map.put("pageable", page.getPageable());
        page.setRows(list("EM_B_REPLY.searchPageEmBReply", map));
        return page;
    }


    @Override
    public int deleteMultipleEmBReply(String replyIdList) {
        int rows = delete("EM_B_REPLY.deleteMultipleEmBReply", replyIdList);
        return rows;
    }

    @Override
    public int updateEmBReplyBat(EmBReply record) {
        int rows = update("EM_B_REPLY.updateEmBReplyBat", record);
        return rows;
    }
}
